package cn.appsys.service.deve.appinfo;

import java.io.File;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.appsys.dao.deve.appinfo.DevAppInfoMapper;
import cn.appsys.pojo.AppInfo;
/**
 * 软件信息实体类业务接口实现类
 * @author Administrator
 *
 */
@Service("devAppInfoService")
public class DevAppInfoServiceImpl implements DevAppInfoService {
	
	@Resource
	private DevAppInfoMapper devAppInfoMapper;
	
	@Override
	public List<AppInfo> queryAppInfoPage(String softwareName, Integer status,
			Integer flatformId, Integer categoryLevel1, Integer categoryLevel2,
			Integer categoryLevel3, Integer from, Integer pageSize) {
		// TODO Auto-generated method stub
		return devAppInfoMapper.queryAppInfoPage(softwareName, status, flatformId, categoryLevel1, categoryLevel2, categoryLevel3, from, pageSize);
	}

	@Override
	public int queryTotalCount(String softwareName, Integer status,
			Integer flatformId, Integer categoryLevel1, Integer categoryLevel2,
			Integer categoryLevel3) {
		// TODO Auto-generated method stub
		return devAppInfoMapper.queryTotalCount(softwareName, status, flatformId, categoryLevel1, categoryLevel2, categoryLevel3);
	}

	@Override
	public AppInfo queryAppInfoByAPKName(String APKName) {
		// TODO Auto-generated method stub
		return devAppInfoMapper.queryAppInfoByAPKName(APKName);
	}

	@Override
	public int addAppInfo(AppInfo info) {
		// TODO Auto-generated method stub
		return devAppInfoMapper.addAppInfo(info);
	}

	@Override
	public AppInfo queryAppInfoById(Integer id,String APKName) {
		// TODO Auto-generated method stub
		return devAppInfoMapper.queryAppInfoById(id,null);
	}

	@Override
	public int upFileById(Integer id) {
		AppInfo info = devAppInfoMapper.queryAppInfoById(id,null);
		if (info!=null&&info.getLogoLocPath()!=null) {
			//通过logo图片绝对路径创建文件对象
			File file = new File(info.getLogoLocPath());
			if (file.exists()) {//判断文件是否存在
				file.delete();//存在就删除
			}
		}
		return devAppInfoMapper.upFileById(id);
	}

	@Override
	public int upAppInfo(AppInfo appInfo) {
		return devAppInfoMapper.upAppInfo(appInfo);
	}

	@Override
	public boolean delAppInfoById(Integer id) {
		AppInfo info = devAppInfoMapper.queryAppInfoById(id,null);
		if (info!=null&&info.getLogoLocPath()!=null) {
			//通过logo图片绝对路径创建文件对象
			File file = new File(info.getLogoLocPath());
			if (file.exists()) {//判断文件是否存在
				file.delete();//存在就删除
			}
		}
		return (devAppInfoMapper.delAppInfoById(id)>0);
	}

}
